<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //防止父类方法被子类重写，为子类申请命名空间
        var namespace1 = {
            eat :function(){
                console.log('这是namespace1的eat方法')
                return []
            },
            play:function(s){
                console.log('这是namespace1的play方法')
            }
        }
        var namespace2 = {
            eat :function(){
                console.log('这是namespace2的eat方法')
                return []
            },
            play:function(s){
                this.eat.push(s)
                console.log('这是namespace2的play方法')
            }
        }
        //方法之间可以通过this进行使用

    </script>
</body>
</html>